package com.lyc.kotlin.wanandroid.uis.activitys

import android.content.Intent
import android.view.animation.AlphaAnimation
import android.view.animation.Animation
import com.lyc.kotlin.wanandroid.R
import com.lyc.kotlin.wanandroid.base.BaseActivity
import kotlinx.android.synthetic.main.activity_splash.*

class SplashActivity : BaseActivity() {

    private var alphaAnimation : AlphaAnimation?=null
    override fun useEventBus(): Boolean =false

    override fun attachLayoutRes(): Int =R.layout.activity_splash

    override fun enableNetwork(): Boolean =false

    override fun start() {
    }

    override fun initView() {
        alphaAnimation= AlphaAnimation(0.3f,1.0f)
        alphaAnimation?.run {
            duration=2000
            setAnimationListener(object :Animation.AnimationListener{
                override fun onAnimationRepeat(animation: Animation?) {
                }

                override fun onAnimationEnd(animation: Animation?) {
                    toMain()
                }

                override fun onAnimationStart(animation: Animation?) {
                }

            })
        }
        layout_splash.startAnimation(alphaAnimation)
    }

    private fun toMain() {
        val intent=Intent(this, MainActivity::class.java)
        startActivity(intent)
        finish()
        overridePendingTransition(R.anim.fade_in,R.anim.fade_out)
    }

    override fun initData() {
    }

}
